﻿Imports System.Data.OleDb
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml
Public Class Feed
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load


        Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\CruisesDB.accdb;Persist Security Info=True"
        Dim dt As New DataTable()
        Dim conn As New OleDbConnection(connectionString)
        Using conn
            '


            Dim ad As New OleDbDataAdapter("SELECT *FROM CruisesTable", conn)
            ad.Fill(dt)
        End Using
        Response.Clear()
        Response.ContentType = "text/xml"
        Dim TextWriter As New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
        TextWriter.WriteStartDocument()  'Below tags are mandatory rss  
        TextWriter.WriteStartElement("rss")
        TextWriter.WriteAttributeString("version", "2.0")
        ' Channel tag will contain RSS feed details 
        TextWriter.WriteStartElement("channel")
        TextWriter.WriteElementString("title", "Voyage List")
        TextWriter.WriteElementString("link", "http://voyage.com")
        TextWriter.WriteElementString("copyright", "Copyright 2012 - 2013  www.voyage.com . All rights reserved.")
        For Each oFeedItem As DataRow In dt.Rows
            TextWriter.WriteStartElement("item")
            
            TextWriter.WriteElementString("title", oFeedItem("CTitle").ToString())
            TextWriter.WriteElementString("description", "Date and time  : " & oFeedItem("Cdate").ToString() & " Country : " & oFeedItem("CCountry").ToString() & " City : " & oFeedItem("CCity").ToString() & " Season : " & oFeedItem("CSeason").ToString() & " Description : " & oFeedItem("CDescription").ToString())


            TextWriter.WriteEndElement()



        Next
        TextWriter.WriteEndElement()
        TextWriter.WriteEndElement()
        TextWriter.WriteEndDocument()
        TextWriter.Flush()
        TextWriter.Close()
        Response.[End]()
    End Sub
End Class

